package com.ln.asset.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ln.asset.core.mapper.TbStatisticsMapper;
import com.ln.asset.core.pojo.TbStatistics;
import com.ln.asset.core.service.TbStatisticsService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhaojiaqi
 * @since 2022-05-02
 */
@Service
public class TbStatisticsServiceImpl extends ServiceImpl<TbStatisticsMapper, TbStatistics> implements TbStatisticsService {

    @Override
    public IPage<TbStatistics> listPage(Page<TbStatistics> pageParam, String keyword) {
        QueryWrapper<TbStatistics> borrowerQueryWrapper = new QueryWrapper<>();

        if(StringUtils.isEmpty(keyword)){
            return baseMapper.selectPage(pageParam, null);
        }

        borrowerQueryWrapper.like("supplyName", keyword)
                .orderByDesc("id");
        return baseMapper.selectPage(pageParam, borrowerQueryWrapper);
    }
}
